<!DOCTYPE html>
<html>

<head>
    <title>游记列表</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travel.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/css/dialog.css">
    <script src="/js/plugins/dialog2/js/dialog.min.js"></script>


    <script>
        /*查询出月推荐的推荐  即type为2*/
        $(function () {
        $.get("/travels/travelCommends",{type:2},function (data) {
            console.log(data);
            $("#travelsCommends").renderValues(data,{
                setHref:function (item,value) {
                    $(item).attr("href",$(item).attr("href")+value);
                }
            })
            $(".carousel-item:first").addClass("active");
        });





            //获取全部游记
            var currentPage = 1;  //定义一个临时当前页变量
            var dataList = [];  //防止jrender丢失上一页数据设置
            var totalPage=1;  //总页数至少为1
            //分页抽取出来的方法
            function query() {
                //查询第一个游记,传入参数pageSize为分页的条数
                $.get("/travels", {pageSize: 5,currentPage:currentPage}, function (data) {
                    dataList = $.merge(dataList, data.list);  //这个方法就是合并两个数组且返回的是第一个数组


                    console.log(data);
                    //数据渲染,注意数据格式应该是{list:[xxxx]}  [xxxx]为一个数组
                    $("#allTravels").renderValues({list: dataList},{
                        setHref:function (item,value) {
                         var href= $(item).attr("href") +value;
                            $(item).attr("href",href);
                        }
                    });

                    currentPage += 1;
                    totalPage = data.pages;
                });
            }
            query();

            //屏幕滚动时间
            $(window).scroll(function () {
                if ($(window).height() + $(window).scrollTop() +1 >= $(document).height()) {
                    if (currentPage <= totalPage) {
                        query();
                    } else {
                        $(document).dialog({
                            type: 'notice',
                            infoText: '人家可是有底线的哦!',
                            autoClose: 2500,
                            position: 'bottom'  // center: 居中; bottom: 底部
                        });
                    }
                }
            });
        })




    </script>
</head>

<body>


<div class="search-head">
    <div class="row nav-search">
        <div class="col-2">
            <a href="index.html">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-10">
            <div class="input-group-sm search">
                <input class="form-control searchBtn" placeholder="搜游记">
            </div>
        </div>
    </div>
</div>


<div class="container">

    <h6>每月冠军游记</h6>
    <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
        <div id="travelsCommends">
            <div class="carousel-inner" render-loop="list">
                <div class="carousel-item">
                    <div class="border commend">
                        <a href="travelContent.html?id=" render-fun="setHref" render-key="list.travelId">
                            <img render-src="list.commendCoverUrl" width="100%" height="200px">
                            <h1 render-html="list.commendTitle"></h1>
                            <small render-html="list.commendSubTitle"></small>
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="sr-only"></span>
        </a>
        <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only"></span>
        </a>
    </div>
</div>

<div class="container">
    <h6>全部游记</h6>
    <div id="allTravels">
        <div render-loop="list">
            <div class="row detail">
                <div class="col">
                    <a href="/travelContent.html?id=" render-fun="setHref" render-key="list.id">
                        <h4 render-html="list.title"></h4>
                    </a>
                    <p>
                        <a href="userProfiles.html">
                            <img class="rounded-circle head-img"
                                 render-src="list.author.headImgUrl">
                            <span render-html="list.author.nickName"></span> </a> 在
                        <span class="addr" render-html="list.place.name"></span>
                    </p>
                    <p>
                        <i class="fa fa-eye fa-fw"></i>
                        <span>0</span>
                        <i class="fa fa-commenting fa-fw"></i>
                        <span>0</span>
                    </p>
                </div>
                <div class="col bigimg">
                    <a href="/travelContent.html?id=" render-fun="setHref" render-key="list.id">
                        <img render-src="list.coverUrl">
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>


</body>

</html>